home *** CD-ROM | disk | FTP | other *** search
-
- ______DRVDIR Ver. 2.00
-
-
-
- Purpose: Batch file utility for use with SWEEP.COM & similar. DrvDir re-
- turns (separately) the current path-&-directory and both the cur-
- ______ rent drive letter spec and the drive number.
-
- Format: DRVDIR [F] [R]
-
- Remarks: Run without parameters DrvDir puts the drive letter (with colon;
- e.g. D:) in DRV. In another environment variable, CUR, it puts
- the current path\directory (e.g. \TP\PROG). Finally, it puts the
- ______ drive number in the DOS Errorlevel. If anything goes wrong, (usu-
- ally because you're out of environment space), the Errorlevel re-
- turns 255. The two options modify this behavior as follows
-
- F (or -F or /F) changes what DrvDir returns in the Errorlevel.
- Instead of the drive number, you get the number of files in the
- directory (up to 254) or 255 to mean failure. You might need
- to know this if you're using a copy utility like Tall Tree's
- JET.COM, which needs to be told explicitly whether to enlarge
- the directory.
-
- R (or -R or /R) changes what's put in the CUR environment vari-
- able: if the current directory is the root directory, CUR will
- carry the value "ROOT" without a preceding backslash. (A di-
- rectory that was really named "ROOT" would be reported as
- "\ROOT".) You may need to use this if you're using a version
- of DOS like 2.1, which can't handle an empty environment vari-
- able.[1]
-
- Why extract and stash this information? A batch file that sweeps
- through a set of directories using a utility like SWEEP.COM (one
- of PC Magazine's) may need to know what the current directory is.
- Say, you have a Bernoulli on drive E: and you want to copy every-
- thing in each directory of the default drive to the corresponding
- directory on E:. Simplified, here's a way to do it. First make a
- batch file STASH.BAT:
-
- DrvDir
- copy %DRV%%CUR%\*.* E:%CUR%
-
- Then, to back up the whole drive, go to the root directory of your
- hard disk, and command: SWEEP STASH
-
- Ordinarily, drive letters are assigned in order of the drive num-
- bers, drive 0 is called A:, 1 is B:, etc. With recent versions of
- -----------
-
-
- 1. I've checked this point under DOS 2.10, which can't handle empty vari-
- ables, and DOS 3.3, which can. I can't speak for other versions. To
- test it for yourself, go to the root directory and run a little batch
- file:
-
- echo off
- DRVDIR
- echo %CUR%
- ______DRVDIR 2.00 Page 2
-
-
- DOS, however, it is possible to create logical drives in such a
- way that the letters don't correspond with the numbers. For this
- reason, DrvDir returns both.[2] Ordinarily, you can use %DRV%%CUR%
- to identify the current drive & directory. If you've done tricky
- things with your drives and the letters come out wrong, you can
- fall back on the errorlevel. You'll have to work it out with a
- series of IF ERRORLEVEL statements. Instead of
-
- drvdir
- copy %DRV%%CUR%\*.* E:%CUR%\
-
- you'd have to use:
-
- drvdir
- if errorlevel 0 if not errorlevel 1 copy A:%CUR%\*.* E:%CUR%
- if errorlevel 1 if not errorlevel 2 copy B:%CUR%\*.* E:%CUR%
- etc.
-
- _____ Notice, by the way that DrvDir never ends the path spec with a
- ______ backslash (\), and always puts a backslash before a subdirectory
- name. Laying aside the R option, %CUR%!==! will be true in the
- root directory and false in any other. Unfortunately, the bug in
- DOS 2.1 ruins this. Since that version of DOS won't return an
- empty variable, even in the root directory (you get things like
- CUR%!) %CUR%!==! will return false. If your batch file may be run
- under DOS 2.1, the R option at least gets you an unmistakeable
- sign that this is the root directory, so you can do clumsy things
- like:
-
- if %CUR%!==ROOT! copy A:\*.* E:\
- if not %CUR%!==ROOT! copy A:%CUR%\*.* E:%CUR%\
-
-
-
- R. N. Wisan, June, 1990
- 37 Clinton St., Oneonta, NY 13820
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -----------
-
-
- 2. Well, I hope it's the "physical" drive number. I'd appreciate word from
- anybody whose logical and physical drives don't match. Tell me whether
- this works.